<?php
/**
 * Created by PhpStorm.
 * User: tengwei
 * Date: 2018/11/16
 * Time: 10:17 AM
 */
namespace common\sources\write\bank;
use common\models\craftsman\BussinessBankAccount;
use Yii;
class BankAccess implements IBankAccess
{
    public function addBdBank($param)
    {
        $res = Yii::$app->db->createCommand()->insert('bussiness_bank_account', [
            'buy_id' => $param['buy_id'],
            'real_name' => $param['real_name'],
            'cardnum' => $param['cardnum'],
            'bankname' => $param['bankname'],
            'pro_name' => $param['pro_name'],
            'pro_code' => $param['pro_code'],
            'city_name' => $param['city_name'],
            'city_code' => $param['city_code'],
            'bankbranch' => $param['bankbranch'],
            'idcard' => $param['idcard'],
            'status' => 2,
            'bankphone' => $param['bankphone'],
            'update_time' => $param['update_time'],
            'create_time' => $param['create_time']
        ])->execute();
        return $res;
    }

    public function modifyBank($param){
        $sql = 'UPDATE ' . BussinessBankAccount::tableName() . ' SET cardnum = :cardnum,bankname = :bankname,pro_name = :pro_name ,pro_code = :pro_code,city_name = :city_name,city_code = :city_code,bankbranch = :bankbranch,bankphone = :bankphone,update_time = :update_time WHERE id = :id ';
        return Yii::$app->db->createCommand($sql)
            ->bindValues([
                ':cardnum' => $param['cardnum'],
                ':bankname' => $param['bankname'],
                ':pro_name' => $param['pro_name'],
                ':pro_code' => $param['pro_code'],
                ':city_name'=> $param['city_name'],
                ':city_code'=> $param['city_code'],
                ':bankbranch' => $param['bankbranch'],
                ':bankphone'=> $param['bankphone'],
                ':update_time' => time(),
                ':id' => $param['b_id']
            ])->execute();
    }

}